package com.liyy.platform.other.reflectProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyHandler implements InvocationHandler {
	private Object myobj;
	//构造方法
	public MyHandler(Object obj) {
		this.myobj=obj;
	}
	
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		before();
		method.invoke(myobj, args);//通过反射调用zhangsan本身的eat方法
		after();
		return null;
	}
	
	public void before(){
		System.out.println("before***吃饭前需要先洗手！");
	}
	
	public void after(){
		System.out.println("after***吃完饭需要先洗手！");
	}

}
